<!DOCTYPE html>
<html lang="ch">
<!--开启session-->
<?php session_start(); ?>
<head>
    <meta charset="utf-8">
    <title>多门店管理系统</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/bootstrap-table.min.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/bootstrap-table.min.js"></script>
    <script src="js/bootstrap-table-zh-CN.min.js"></script>

    <!--    js获取日期-->
    <script>
        $(function time() {
            var now = new Date();
            var year = now.getFullYear();
            var month = now.getMonth();
            var date = now.getDate();
            //获取相应ID
            document.getElementById("timer").innerHTML = "时间：" + year + "年" + (month + 1) + "月" + date + "日";
        })
    </script>
    <!--    table显示-->
    <script>
        $(function () {
            $('#mytab').bootstrapTable('destroy');
            $('#mytab').bootstrapTable({
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",//不变
                method: "post",//不变
                dataType: "json",//不变
                url: "6.2RequestFromMe.php",//改成目标php
                // data:[{
                //     'id':'233',
                //     'name':'lisi'
                // },{'id':'...','name':'...'}],
                sortOrder: "asc",                   //排序方式
                showExport: true,                     //是否显示导出为excel的按钮
                exportDataType: "basic",              //basic', 'all', 'selected'
                striped: true, //是否显示行间隔色
                pageNumber: 1, //初始化加载第一页
                pagination: true,//是否分页
                sidePagination: 'client',//server:服务器端分页|client：前端分页
                pageSize: 5,//单页记录数
                pageList: [5, 10, 20, 30, 50],//可选择单页记录数
                showRefresh: false,//刷新按钮
                queryParams: function getParams(params) {//上传服务器的参数
                    return params;
                },
                columns: [
                    {
                        title: "序号",
                        field: "index",
                        align: 'center',
                        formatter: function (value, row, index) {
                            return index + 1;
                        }
                    },
                    {
                        title: "商品编号",
                        field: "good_id",
                        align: 'center', //center居中，left左对齐，right右对齐
                        sortable: true,
                    },

                    {
                        title: '款式',
                        field: 'style',
                        align: 'center',
                        // sortable : true
                    },
                    {
                        title: '颜色',
                        field: 'color',
                        align: 'center',
                        // sortable : true
                    },
                    {
                        title: '尺码',
                        field: 'size',
                        align: 'center',
                        // sortable : true
                    },
                    {
                        title: '被申请店',
                        field: 'ans_shop',
                        align: 'center',
                    },
                    {
                        title: '申请数量',
                        field: 'num',
                        align: 'center',
                    },
                    {
                        title: '状态',
                        field: 'status',
                        align: 'center',
                    },
                    {
                        title: '操作',
                        field: 'option',
                        align: 'center',
                        events: operatEvents,
                        formatter: operatFrom,
                    },

                ]
            });
        });

        function operatFrom(value, row, index) {
            //return "<a href='javascript:;' οnclick='editRow(event)'>编辑</a>&nbsp;&nbsp;<a href='javascript:;' οnclick='deleteRow(event)'>删除</a>";
            var trans_status = row.status;
            if (trans_status == "被接受") {
                var sell_button = '<button type="button" class="btn btn-success btn-sm" id="confirm" style="margin-right:15px;">确认</button>';
            } else if (trans_status == "等待对方审批") {
                var sell_button = '<button type="button" class="btn btn-primary btn-sm" id="cancel" style="margin-right:15px;">取消</button>';
            } else {
                var sell_button = '<button type="button" class="btn btn-danger btn-sm" id="delete" style="margin-right:15px;">删除</button>';
            }
            return [
                sell_button]
                .join('');
        }

        window.operatEvents = {
            "click #confirm": function (e, value, row, index) {
                $.ajax({
                    type: "POST",
                    url: "6.2.1OpFromMe.php",
                    dataType: "json",
                    data: {
                        trans_id: row.id
                    },
                    success: function (responseText) {
                    }
                });
                alert("已确认，调货加入本店库存");
                history.go(0);
            },
            "click #cancel": function (e, value, row, index) {
                $.ajax({
                    type: "POST",
                    url: "6.2.1OpFromMe.php",
                    dataType: "json",
                    data: {
                        trans_id: row.id
                    },
                    success: function (responseText) {
                    }
                });
                alert("已取消申请");
                history.go(0);
            },
            "click #delete": function (e, value, row, index) {
                $.ajax({
                    type: "POST",
                    url: "6.2.1OpFromMe.php",
                    dataType: "json",
                    data: {
                        trans_id: row.id
                    },
                    success: function (responseText) {
                    }
                });
                alert("已删除申请");
                history.go(0);
            }
        }
    </script>
</head>

<body style="background: #eeeeee">
<div class="jumbotron text-center" style="margin-bottom:0; ">
    <h1>多门店管理系统</h1>
    <div id="timer" style="float: right; font-size: 20px; "></div>
</div>

<nav class="navbar navbar-inverse">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
        </div>
        <div class="collapse navbar-collapse" id="myNavbar">
            <ul class="nav navbar-nav">
                <li><a href="main.php" style="font-size: 20px;">我的信息</a></li>
                <li><a href="search.php" style="font-size: 20px;">库存查询</a></li>
                <li><a href="purchase.php" style="font-size: 20px;">进货</a></li>
                <li><a href="sell.php" style="font-size: 20px;">售货</a></li>
                <li><a href="less.php" style="font-size: 20px;">缺货情况</a></li>
                <li><a href="transfer1.php" style="font-size: 20px;">发出的申请</a></li>
                <li><a href="transfer2.php" style="font-size: 20px;">收到的申请</a></li>
                <li><a href="statistic1.php" style="font-size: 20px;">本店销售排名</a></li>
                <li><a href="statistic2.php" style="font-size: 20px;">销售记录</a></li>
            </ul>
        </div>
    </div>
</nav>


<div class="container">
    <div class="row">
        <div class="col-md-8" style="height: 1000px;">
            <h3>我发出的申请：</h3>
            <hr/>
            <table class="table table-striped" id="mytab"></table>
        </div>
        <div class="col-md-4">
            <div style="float: right;">
                <div id="all">
                    <div class="content" style="text-align: center; border: 1px solid #000000;">
                        <img width="200px" height="200px" src="img/xyq0411.jpg"/>
                        <p>姓名：<?php echo $_SESSION['user']['name']; ?></p>
                        <p>职位：<?php echo $_SESSION['user']['type']; ?></p>
                        <p>所在店：<?php echo $_SESSION['user']['shop_id']; ?></p>
                        <p>用户名：<?php echo $_SESSION['user']['id']; ?></p>
                        <p>
                            <button type="button" onclick="window.location.href='0.2LogOut.php'"
                                    class="btn btn-primary btn-lg ">注销
                            </button>
                        </p>
                    </div>
                </div>
            </div>
            <div style="float: right; margin-top: 20px;">
                <div id="xiaoxun">
                    <div class="content" style="text-align: center; border: 3px solid #B21F2D;">
                        <p style="font-size: 46px; color: #B21F2D;">明德 厚学</p>
                        <p style="font-size: 46px; color: #B21F2D;">求是 创新</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

</body>
</html>